<script>
    function confirmDeleteSelected(){
        if($('#option').val()=='delete'){
            if (confirm('Bạn có chắc chắn muốn xóa các mục đã chọn không?')){
                return true;
            }
            else return false;
        }
    }
</script>
<!-- Page Head -->
<!-----------------------------------
 * @author  :   Yêu Tinh
 * @email   :   domain.web.online@gmail.com
 * @since   :   8-07-2013
 ------------------------------------>
 
<script type="text/javascript" src="<?php echo DOMAINAD;?>source/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="<?php echo DOMAINAD;?>source/jquery.fancybox.js?v=2.1.5"></script>
<link rel="stylesheet" type="text/css" href="<?php echo DOMAINAD;?>source/jquery.fancybox.css?v=2.1.5" media="screen" />
<script type="text/javascript">
	$(document).ready(function() {
		$('.fancybox').fancybox();
	});
</script>
<style type="text/css">
	.fancybox-custom .fancybox-skin {
		box-shadow: 0 0 50px #222;
	}
</style>

<ul style="float: right;" class="shortcut-buttons-set">
	
	<li><a class="shortcut-button png48-add" href="<?php echo DOMAINAD.strtolower(basename(dirname(__FILE__)));?>/add"><span class="png_bg">
		Thêm mới
	</span></a></li>
	
	<li><a class="shortcut-button png48-info" href="#messages"><span class="png_bg">
		Trợ giúp
	</span></a></li>
	
	<li><a class="shortcut-button png48-exit" href="<?php echo DOMAINAD; ?>"><span class="png_bg">
		Đóng
	</span></a></li>

</ul><!-- End .shortcut-buttons-set -->

<div class="clear"></div> <!-- End .clear -->


<?php echo $this->Session->flash(); ?>


<div class="content-box"><!-- Start Content Box -->
	<div class="content-box-header">
    
    
		<h3>Danh sách thành viên</h3>

        <?php echo $this->Form->create(null, array('url' => DOMAINAD . strtolower(basename(dirname(__FILE__))). '/search', 'type' => 'post', 'name' => 'adminFrom', 'inputDefaults' => array('label' => false, 'div' => false, 'legend'=> false))); ?>
            <?php echo $this->Form->input(null,array('name'=>'search_keyword','value'=>$this->Session->read('search_keyword'),'class'=>'text-input', 'placeholder' => 'Nhập email khách hàng'));?>
            <input type="submit" name="" value="Tìm kiếm" class="button" />
        <?php echo $this->Form->end(); ?>
        
		<div class="clear"></div>
	</div> <!-- End .content-box-header -->
	<div class="content-box-content">
		<div class="tab-content default-tab" id="tab1"> <!-- This is the target div. id must match the href of this div's tab -->
            <?php echo $this->Form->create(null, array('onsubmit' => 'return confirmDeleteSelected();','url' => DOMAINAD . strtolower(basename(dirname(__FILE__))). '/index', 'type' => 'post', 'name' => 'abc', 'inputDefaults' => array('label' => false, 'div' => false, 'legend'=> false))); ?>
			<table>
                <thead>
                        <tr>
                            <th>STT</th>
                            <th>Tên</th>
                            <th>Email</th>
                            <th>Điểm</th>
                            <th>Cộng điểm</th>
                            <th>Cập nhật</th>
                            <th>Xử lý</th>
                            <th>ID</th>
                        </tr>
                </thead>
                <tbody>
                    <?php foreach ($view as $key => $value) { ?>
                    <tr>
                        <td><?php echo $key + $this->Paginator->counter('{:start}');?></td>
                        <td><?php echo $value['User']['fullname']; ?></td>
                        <td><?php echo $value['User']['email']; ?></td>
                        <td><?php echo $value['User']['point']; ?></td>
                        <td>
                            <a class="fancybox" href="#inline<?php echo $key + $this->Paginator->counter('{:start}');?>" title="<?php echo $value['User']['email']; ?>">
                                <input type="button" value="Cộng điểm"/>
                            </a>
                        </td>
                        <td><?php echo date('d-m-Y', strtotime($value['User']['modified'])); ?></td>
                        <td>
                            <?php if ($value['User']['status'] == 0) {?>
                                <a href="<?php echo DOMAINAD.strtolower(basename(dirname(__FILE__)));?>/active/<?php echo $value['User']['id']; ?>" title="Kích hoạt" class="icon-5 info-tooltip"><img src="<?php echo DOMAINAD ?>img/lotus/icons/cross_circle.png" alt="Kích hoạt" /></a>
                            <?php } else {?>
                                <a href="<?php echo DOMAINAD.strtolower(basename(dirname(__FILE__)));?>/close/<?php echo $value['User']['id']; ?>" title="Đóng" class="icon-4 info-tooltip"><img src="<?php echo DOMAINAD ?>img/lotus/icons/tick_circle.png" alt="Ngắt kích hoạt" /></a>
                            <?php }?>
                        </td>
                        <td align="right"><?php echo $value['User']['id']; ?></td>
                    </tr>
                    <?php } ?>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="9">
                            
                            <?php if($this->Paginator->numbers()){?>
                            <div class="pagination">
                                <?php
                                    echo $this->Paginator->first('« Đầu');     
                                    echo $this->Paginator->prev('« Trước', null, null, array('class' => 'disabled')); 
                                    echo $this->Paginator->numbers(
                                        array(
                                            'before' => null,
                                            'after' => null,
                                            
                                			'tag' => 'span',
                                            'class' => 'number',
                                			'modulus' => '6',
                                            'separator' => null,
                                            'first' => 2,
                                            'last' => 2,
                                            'ellipsis' => '...',
                                			'currentClass' => 'current',
                                            'currentTag' => null
                                		)
                                    );
                                    echo $this->Paginator->next('Tiếp »'); 
                                    echo $this->Paginator->last('Cuối »'); 
                                    echo $this->Paginator->counter('Trang {:page}/{:pages}. Đang xem {:current}/{:count} (từ {:start} đến {:end}).');
                                ?>
                            </div>
                            <?php }?>
                            <div class="clear"></div>
                        </td>
                    </tr>
                </tfoot>
			</table>
            <?php echo $this->Form->end();?>
            
            <?php foreach ($view as $key => $value) { $ik = $key + $this->Paginator->counter('{:start}');?>
                <div id="inline<?php echo $key + $this->Paginator->counter('{:start}');?>" style="width:500px;display: none;">
            		<h3>Cộng điểm - <span style="font-style: italic;"><?php echo $value['User']['email']; ?></span></h3>
            		<p>
            			<?php echo $this->Form->create(null, array('url' => DOMAINAD . strtolower(basename(dirname(__FILE__))). '/congdiem/'.$value['User']['id'], 'type' => 'post', 'name' => 'adminFrom'.$ik, 'inputDefaults' => array('label' => false, 'div' => false, 'legend'=> false))); ?>
                            <?php echo $this->Form->input('User.point', array('class' => 'text-input medium-input', 'maxlength' => '20', 'placeholder' => 'Nhập điểm cộng')); ?>
                            <input type="submit" value="Cộng điểm"/>
                            <div style="padding: 8px; border: 1px solid #efefef; margin-top: 10px;">
                                <?php 
                                    $goicmt = null;
                                    $goicmt = $this->requestAction('/users/goicmt/'.$value['User']['id']);
                                    foreach($goicmt as $val){
                                ?>
                                <p style="padding: 2px 5px; border-bottom: 1px dotted #efefef;"><?php echo $val['Cmtaction']['content'];?></p>
                                <?php }?>
                            </div>
                        <?php echo $this->Form->end(); ?>
            		</p>
            	</div>
            <?php }?>
            
		</div> <!-- End #tab1 -->       
	</div> <!-- End .content-box-content -->
</div> <!-- End .content-box -->




<ul style="float: right;" class="shortcut-buttons-set">
	
	<li><a class="shortcut-button png48-add" href="<?php echo DOMAINAD.strtolower(basename(dirname(__FILE__)));?>/add"><span class="png_bg">
		Thêm mới
	</span></a></li>
	
	<li><a class="shortcut-button png48-info" href="#messages"><span class="png_bg">
		Trợ giúp
	</span></a></li>
	
	<li><a class="shortcut-button png48-exit" href="<?php echo DOMAINAD; ?>"><span class="png_bg">
		Đóng
	</span></a></li>

</ul><!-- End .shortcut-buttons-set -->

<div class="clear"></div>